package DMSXL._2023Before.Tree;

import java.util.ArrayList;
import java.util.List;

public class postorderTraversal {
    public static void main(String[] args) {

    }
    List<Integer> list = new ArrayList<>();
    public List<Integer> postorderTraversal(TreeNode root) {
        if(root == null)
            return list;
        posterOrder(root);


        return list;
    }
    public void posterOrder(TreeNode root){
        if(root == null){
            return;
        }

        posterOrder(root.left);
        posterOrder(root.right);
        list.add(root.val);
    }
}
